﻿using System;
using TopWinCMS.BLL;
using TopWinCMS.Common;
using TopWinCMS.Model;
using TopWinCMS.WebFactory;

namespace TopWinCMS.WebUI.Views.TopWinCMS6.Member
{
    public partial class Information : ClientPublicPage
    {
        Public_Member MyClassBLL = new Public_Member(false);
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "资料修改";
            if (!IsPostBack)
            {
                UserInfo model = new UserManage().GetInfo(UserManage.Current.UserID);

                if (model != null)
                {
                    this.TB_HomePage.Text = model.HomePage;
                    this.TB_QQ.Text = model.QQ;
                    this.TB_PetName.Text = model.PetName;
                    this.TB_Introduce.Text = model.Introduce;
                    this.TB_email.Text = model.EMail;

                    this.TB_Question.Text = model.Question;
                    this.TB_Answer.Text = model.Answer;
                    this.RBL_Sex.SelectedValue = model.Sex.ToString();
                    this.TB_TrueName.Text = model.TrueName;
                    this.TB_MSN.Text = model.Msn;
                    this.TB_Birthday.Text = model.Birthday;
                    //TB_Province.Text = model.Province;
                    //TB_City.Text = model.City;
                    this.TB_ICQ.Text = model.Icq;
                    this.TB_Yahoo.Text = model.Yahoo;
                    this.TB_Skype.Text = model.Skype;
                    //TB_Location.Text = model.Location;
                    this.TB_IdCard.Text = model.IdCard;
                    this.TB_Mobile.Text = model.Mobile;
                    this.TB_Phone.Text = model.Phone;
                    this.TB_Address.Text = model.Address;
                }
            }
        }


        protected void BT_Edit_Click(object sender, EventArgs e)
        {
            if (RightsCheck.IsLogined == false)
            {
                MsgBox.Message("登录超时，请重新登录。", "Login.aspx", this);
            }
            UserInfo model = new UserManage().GetInfo(UserManage.Current.UserID);


            model.HomePage = this.TB_HomePage.Text.Trim();
            model.QQ = this.TB_QQ.Text.Trim();
            model.PetName = this.TB_PetName.Text.Trim();
            model.Introduce = this.TB_Introduce.Text.Trim();
            model.EMail = this.TB_email.Text.Trim();

            model.Question = this.TB_Question.Text.Trim();
            model.Answer = this.TB_Answer.Text.Trim();
            model.Sex = byte.Parse(this.RBL_Sex.SelectedValue);
            model.TrueName = this.TB_TrueName.Text.Trim();
            model.Msn = this.TB_MSN.Text.Trim();

            model.Birthday = this.TB_Birthday.Text.Trim();
            model.Province = string.Empty;
            model.City = string.Empty;
            model.Icq = this.TB_ICQ.Text.Trim();
            model.Yahoo = this.TB_Yahoo.Text.Trim();

            model.Skype = this.TB_Skype.Text.Trim();
            model.Location = string.Empty;
            model.IdCard = this.TB_IdCard.Text.Trim();
            model.Mobile = this.TB_Mobile.Text.Trim();
            model.Phone = this.TB_Phone.Text.Trim();
            model.Address = this.TB_Address.Text.Trim();

            string Err = null;

            this.MyClassBLL.EditByMemberSelf(model, ref Err);

            if (string.IsNullOrEmpty(Err) == false)
            {
                MsgBox.Message(Err, this.UpdatePanel1);
            }
            else
            {
                MsgBox.Message("修改成功!", this.UpdatePanel1);
            }
        }
    }
}